package controle;

import java.sql.*;

import org.jfree.data.category.DefaultCategoryDataset;

public class RetornaItensBD{
  
	
	public static DefaultCategoryDataset retornaSet(){
		DefaultCategoryDataset ds = new DefaultCategoryDataset();
		
		
		try {
		      Class.forName("org.sqlite.JDBC");
		      Connection c = DriverManager.getConnection("jdbc:sqlite:C:\\registro.db");
		      c.setAutoCommit(false);
		      

		      Statement stmt = c.createStatement();
		      ResultSet rs = stmt.executeQuery( "SELECT * FROM EVENTOS;" );
		      
		      while ( rs.next() ) {
		    	 
		         String  valor = rs.getString("VALOR");
		         String  hora =  rs.getString("HORA");
		         String  data =  rs.getString("DATA");
		         
		         ds.addValue(Double.parseDouble(valor), "maximo", hora);
		         
		      }
		      rs.close();
		      stmt.close();
		      c.close();
		    } catch ( Exception e ) {
		      System.err.println( e.getClass().getName() + ": " + e.getMessage() );
		      System.exit(0);
		    }
		    
		
		return ds;
		
	}
}